<template>
  <div class="status-change">
    <el-form label-width="120px">
      <el-form-item label="当前状态变更为">
         <el-select v-model="statusNumber" placeholder="请选择">
           <el-option v-for="item in options"
             :key="item.value"
             :label="item.label"
             :value="item.value"></el-option>
         </el-select>
      </el-form-item>
      <el-button @click="onCancel">取 消</el-button>
      <el-button type="primary" @click="onSubmit">确 定</el-button>
    </el-form>
  </div>
</template>

<script>
import { saveOrUpdateSection } from '@/services/section'
export default {
  name: 'StatusChange',
  props: {
    status: {
      type: Number
    },
    sectionName: {
      type: String
    }
  },
  data () {
    return {
      options: [{
        value: 2,
        label: '已更新'
      }, {
        value: 1,
        label: '待更新'
      }, {
        value: 0,
        label: '已隐藏'
      }],
      statusNumber: this.status,
      formLabelWidth: '120px'
    }
  },
  methods: {
    onCancel () {
      this.$emit('cancelStatus')
    },
    async onSubmit () {
      // console.log(this.statusNumber)
      const { data } = await saveOrUpdateSection({
        status: this.statusNumber,
        sectionName: this.sectionName
      })
      // console.log(data)
      if (data.code === '000000') {
        this.$emit('changeStatus', this.options, this.statusNumber)
      }
      console.log(this.options)
      console.log(this.statusNumber)
    }
  }
}

</script>
<style lang="scss" scoped></style>
